package com.liam.design.observer;

import com.liam.design.observer.obs.WeatherObserver;
import com.liam.design.observer.sub.WeatherSubject;

public class Test {

    public static void main(String[] args) {
        // 创建目标
        WeatherSubject weatherSubject = new WeatherSubject();

        // 创建观察者
        WeatherObserver obs1 = new WeatherObserver();
        obs1.setName("obs1");

        WeatherObserver obs2 = new WeatherObserver();
        obs2.setName("obs2");

        // 注册观察者

        weatherSubject.attach(obs1);
        weatherSubject.attach(obs2);

        // 目标发布信息
        weatherSubject.setContent("天气晴朗");
    }
}
